﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Aulac.Rsc.Bss;
using Aulac.Rsc.Bss.Tags;
using System.Threading;

using Aulac.Client.Global.Member;
using Aulac.Verb.Ems;
using Aulac.Global.Xml;
using Aulac.Client.Global.Ems.Member;
using Aulac.Rsc.Ems;

namespace Aulac.Client.Controls.Forms.Bss
{
    public partial class FormEmsMainBase : Aulac.Client.Controls.Forms.FormMainBase01
    {
        public FormEmsMainBase()
        {
            InitializeComponent();
        }
        #region Ovrride Methods
        public override void OnFormLoad()
        {
            Aulac.Client.Global.Ems.Member.AulacEmsGlobalMember.AulacConnectSrv = new Aulac.Client.Connect.Ems.AulacEmsLanConnect(); 

            InitOption();
            if (OnLogIn())
                InitGlobalMember();

        }
        protected override bool OnLogIn()
        {
            return false;
        }

        #endregion

        #region Private Methods
        private void InitOption()
        {
            Options SysOption = null;
            try
            {
                XmlDataDocument doc = DataRequest.CreateXmlDocument(AulacEmsVerb.System.GetSystemOption, AulacEmsVerb.System.Noun.System);
                doc = DataRequest.ProcessRequest(doc);
                XmlElement node = XmlProcess.GetVchHeaderElm(doc);
                SysOption = new Options(node);
            }
            catch
            {
                SysOption = new Options();
            }



            Aulac.Global.Enums.DateFormats dFormat = SysOption.DateFormat;

            System.Globalization.CultureInfo l_CultureInfo = Aulac.Global.Common.DateTimeHelper.DateTimeFormat.CreateCultureInfo(SysOption.DateFormat);

            l_CultureInfo.NumberFormat.NumberDecimalSeparator = SysOption.IsCommaSeperate ? "," : ".";
            l_CultureInfo.NumberFormat.NumberGroupSeparator = SysOption.IsCommaSeperate ? "." : ",";
            l_CultureInfo.NumberFormat.NumberDecimalDigits = SysOption.DecimalRound;
            l_CultureInfo.DateTimeFormat.ShortDatePattern = (SysOption.IsDayMonth) ? Aulac.Global.Common.DateTimeHelper.DateTimeFormat.dd_MM_yyyy : Aulac.Global.Common.DateTimeHelper.DateTimeFormat.MM_dd_yyyy;
            l_CultureInfo.DateTimeFormat.ShortTimePattern = Aulac.Global.Common.DateTimeHelper.DateTimeFormat.HH_mm_ss;
            Thread.CurrentThread.CurrentCulture = l_CultureInfo;

            //AulacEmsGlobalMember.SysOption = SysOption;
            AulacEmsGlobalMember.CultureInfo = l_CultureInfo;
            AulacEmsGlobalMember.DateFormat = SysOption.DateFormat;
            AulacEmsGlobalMember.DateTimeServer = SysOption.ServerDate;
            
        }
        private void InitGlobalMember()
        {
            Aulac.Client.Global.Member.GlobalDatasCache.CreateDataSetCache("DataHospital");
            //Aulac.Client.Global.Ems.Member.AulacEmsGlobalMember.CompanyInfo = InitCompany();
        }
        //public CompanyInfo InitCompany()
        //{
        //    try
        //    {
        //        XmlDataDocument doc = DataRequest.CreateXmlDocument(AulacEmsVerb.System.GetCompanyInfo, AulacEmsVerb.System.Noun.System);
        //        doc = DataRequest.ProcessRequest(doc);
        //        CompanyInfo cmp = new CompanyInfo(doc);

        //         this.Text = "Hệ thống quản lý viện phí " + cmp.HspName;
        //        return cmp;
        //    }
        //    catch
        //    {
        //        this.Text = "Hệ thống quản lý viện phí ";
        //        return null;
        //    }
        //}

        #endregion


        #region Properties

        #endregion
        #region Menu Methods




        #endregion
    }
}
